<div class="layuimini-container layui-anim layui-anim-upbit">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="" id="form">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">数据库名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="jobNumberSearch" autocomplete="off" class="layui-input"
                                    id="jobNumber">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit
                                lay-filter="data-search-btn"
                                style="margin-left:10px;width:90px;height:38px;border:none;outline:none;border-radius:6px;background-color:#007bff;color:white"><i
                                    class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <br>
        <div id="table" lay-filter="currentTableFilter">
        </div>
        <div id="page"></div>
    </div>
</div>

<script type="text/html" id="currentTableBar">
  <a class="layui-btn layui-btn-xs layui-btn-normal data-count-edit" lay-event="editInfo">提交样式配置</a>
</script>

<script type="text/html" id="isConfiged">
  {{# if(d.templateConig ==true){ }}
  <i class="layui-icon layui-icon-ok" style="font-size: 30px; color: #00CC33;"></i>  
  {{# } else { }}
  <i class="layui-icon layui-icon-close" style="font-size: 30px; color: 	#CC6633;"></i>  
  {{# } }}
</script>


<script type="text/html" id="checkboxTpl">
    <input type="checkbox" name="showToCustomer" value="{{d.databasecode}},{{d.databasename}}"  lay-skin="switch" lay-text="可见|不可见" lay-filter="sexDemo" {{ d.showToCustomer == true ? 'checked' : '' }}>
</script>


<script>
    var tableBar = [
        { title: '序 号', type: 'numbers', width: '5%', align: "center" },
        { field: 'databasename', title: '数据库名称', width: '30%', align: "center" },
        { field: 'name', title: '数据库类型', width: '25%', align: "center" },
        { title: '用户是否可见', width: '15%', align: "center", templet: '#checkboxTpl' },
        { field: 'showDepartment', title: '是否提交样式配置', width: '15%', align: "center", templet: '#isConfiged' },
        { title: '操 作', width: '10%', templet: '#currentTableBar', align: "center" }
    ]

    var initTableParams = {
        "DATABASENAME": "",
        "orderType": "CREATEDATE",
        "orderValue": "desc",
        "page": 1,
        "pageSize": 10
    }


    layuiEx.tableRender(
        "/DIYTag/list",
        'table',
        'page',
        tableBar,
        initTableParams
    );


    layui.use(['form'], function () {
        var form = layui.form
    })

    //检索事件
    layui.form.on('submit(data-search-btn)', function (params) {
        layuiEx.tableRender(
            "/DIYTag/list",
            'table',
            'page',
            tableBar,
            {
                "DATABASENAME": params.field.jobNumberSearch,
                "orderType": "CREATEDATE",
                "orderValue": "desc",
                "page": 1,
                "pageSize": 10
            }
        );
        return false
    })


    layui.table.on('tool(currentTableFilter)', function (obj) {
        debugger
        var data = obj.data;
        if (obj.event === 'resetPwd') {
            //
        }
        else if (obj.event === 'editInfo') {

            loadAdduserPage("edit", data)
        }
        else if (obj.event === 'deleteInfo') {
            //
        }
    });



    //提交样式配置的弹出页面
    function loadAdduserPage(addORedit, data) {
        var content = layui.miniPage.getHrefContent('mypages/DIYTag/2.html');
        var openWH = layui.miniPage.getOpenWidthHeight();
        var title = ""
        if (addORedit == "add") {
            title = "添加用户"
        } else {
            title = "样式配置"
        }
        //不能用 var 前缀
        data_userMgr = data
        var index = layer.open({
            title: title,
            type: 1,
            shade: 0.2,
            maxmin: true,
            shadeClose: true,
            offset: '100px',
            area: ['1200px', '800px'],
            content: content,
              end: function () {
                  var trunToPage = 1
                  if (addORedit=="add") {

                  }else{
                      trunToPage = $(".layui-laypage-em").next().html()
                  }
                  layuiEx.tableRender(
                       "/DIYTag/list", 
                      'table',
                      'page',
                      tableBar,
                      {
                          "DATABASENAME":$("#jobNumber").val(),
                          "orderType":"CREATEDATE",
                          "orderValue":"desc",
                          "page":1,
                          "pageSize":10
                      }
                  );
              }
        });
        $(window).on("resize", function () {
            layer.full(index);
        });
        return false;
    }



</script>